<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <script>

        class Person{

            constructor(name, age){
                this.name = name;
                this.age = age;
            }

            getName(){
                console.log(this.name);
            }
        }

        class Student extends Person{
            constructor(name, age, sno){
                super(name, age); //调用父类的构造函数
                this.sno = sno;
            }

            getSno(){
                console.log(this.sno);
            }

            // 重写父类的方法
            getName(){
                console.log('Student name is ' + this.name);
            }

            // 在子类的方法中调用父类的方法
            getParentName(){
                super.getName(); //调用父类的方法
            }
        }

    </script>
</body>
</html>